const state = {
  faultDetail: {},
  chooseListObj: {},
  showEqList: [
    {
      text: "输电巡检", id: 1, hasChildren: true, subRow: [
        {
          text: "110kV线路", id: '0111', hasChildren: true, subRow: [
            {
              text: "110kV白糖变", id: '011', hasChildren: true, subRow: [
                {
                  id: 11, text: "线路", dydj: "交流10kV", hasChildren: false, subRow: [
                    { id: "rwer11", text: "设备1", dydj: "交流10kV" },
                    { id: "rwereq11", text: "设备2", dydj: "交流10kV" },
                    { id: "ewqeqewq", text: "设备3", dydj: "交流10kV" }
                  ],
                },
                {
                  id: 12, text: "线路2", dydj: "交流10kV", hasChildren: false, subRow: [
                    { id: "rwer11", text: "设备1", dydj: "交流10kV" },
                    { id: "rwereq11", text: "设备2", dydj: "交流10kV" },
                    { id: "ewqeqewq", text: "设备3", dydj: "交流10kV" }
                  ],
                },
                {
                  id: 13, text: "线路3", dydj: "交流10kV", hasChildren: false, subRow: [
                    { id: "rwer11", text: "设备1", dydj: "交流10kV" },
                    { id: "rwereq11", text: "设备2", dydj: "交流10kV" },
                    { id: "ewqeqewq", text: "设备3", dydj: "交流10kV" }
                  ],
                }
              ], "itemType": "2c902a9c4a9ededc014a9f3c78f70006#zwyc_xl"
            }
          ],
        }
      ],
    }
  ],
  uploadFile: {}
}
const getters = {

}
const mutations = {
  update_faultDetail (state, val) {
    state.faultDetail = val;
  },
  update_chooseListObj (state, val) {
    state.chooseListObj = val;
  },
  update_showEqList (state, val) {
    state.showEqList = val
  },
  update_uploadFile (state, val) {
    state.showEqList = val 
  },
  //新增设备
  add_selectEqList (state, val) {
    if (!state.chooseListObj.valList) {
      state.chooseListObj.valList = []
    }
    var has = state.chooseListObj.valList.some(i => val.id == i.id);
    if (!has) {
      state.chooseListObj.valList.unshift(val)
    }
  },
  //删除设备
  delete_selectEqList (state, val) {
    if (!state.chooseListObj.valList) {
      state.chooseListObj.valList = []
    }
    var index = state.chooseListObj.valList.findIndex(i => val.id == i.id);
    if (index > -1) {
      state.chooseListObj.valList.splice(index, 1)
    }
  },
}
const actions = {
}

export default {
  state,
  getters,
  actions,
  mutations
}

